package 剑指offer;

/**
 * @author zhangjunfei
 * @date 2023/7/19 10:55
 */
public class O_42 {

    public int maxSubArray(int[] nums) {
        int max = nums[0];
        for (int i = 1; i < nums.length; i++) {
            nums[i] += Math.max(nums[i - 1], 0);
            max = Math.max(nums[i], max);
        }
        return max;
    }
}
